package org.course.weather.util;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

public class MyUtil {
    private static final DateTimeFormatter date_time_format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public static String DTStr(LocalDateTime dateTime) {
        return date_time_format.format(dateTime);
    }

    public static LocalDateTime StrDT(String dateTimeStr) {
        return LocalDateTime.parse(dateTimeStr, date_time_format);
    }

    public static String TimeTStr(int time_stamp) {
        return date_time_format.format(LocalDateTime.ofInstant(Instant.ofEpochSecond(time_stamp),  ZoneId.systemDefault()));
    }
}
